// pages/myself/mycollect.js
var util = require('../../utils/util.js');
const app = getApp();
var page = 1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listInfo: [],
    orderList:[],
    allmoeny:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    page = 1;
  },
  //滚动到底部刷新
  onReachBottom: function () {
    this.getDownorder();
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      listInfo: app.globalData.listInfo
    })
    this.getDownorder();
  },
  getDownorder:function(){
    var that=this;
    var limit = 10;
    wx.request({
      url: app.globalData.hostUrl + 'member/downorderlist',
      data: {
        uid: wx.getStorageSync('userId'),
      },
      method: 'GET',
      success: function (res) {
        page++;
        //.log(res);
        that.setData({
          orderList: res.data.result.list,
          allmoeny: res.data.result.allmoney
        })
      },
      fail: function (res) {
        console.log(res.data);
        console.log('is failed')
      }
    })
  },
  gohome: function () {
    wx.redirectTo({
      url: '../index/index',
    })
  },
  yuy: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../myself/thappointment',
      })
    }
    else {
      wx.redirectTo({
        url: '../myself/myappointment',
      })
    }
  },
  orders: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../myself/trorder',
      })
    }
    else {
      wx.redirectTo({
        url: '../myself/myorder',
      })
    }
  },
  mys: function () {
    wx.redirectTo({
      url: '../myself/myself',
    })
  },
  onShareAppMessage: function () {

  }
})